﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace StateMachineXNA
{
    class Timer
    {
        double time;
        double duration;

        public Timer(double duration)
        {
            time = 0;
            this.duration = duration;
        }

        public Timer(double duration, double start)
        {
            time = start;
            this.duration = duration;
        }

        public double ElapsedTime
        { get { return time; } }

        public bool Increment(double delta_time)
        {
            time += delta_time;
            return time > duration;
        }

        public bool Finished()
        { return time > duration; }

        public void Restart(bool cyclic = false)
        {
            if (cyclic) time -= duration;
            else time = 0;
        }
    }
}
